package com.hkx.smipleemps.servlet;

import com.hkx.smipleemps.common.domain.Admin;
import com.hkx.smipleemps.common.domain.Employee;
import com.hkx.smipleemps.service.AdminService;
import com.hkx.smipleemps.service.AdminServiceImpl;
import com.hkx.smipleemps.service.EmployeeService;
import com.hkx.smipleemps.service.EmployeeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/toUpdateEmp.do")
public class ToUpdateEmployeeServlet extends HttpServlet {
    EmployeeService employeeService = new EmployeeServiceImpl();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String idStr = request.getParameter("id");// "1"  ----> 1
        Integer id = Integer.parseInt(idStr);//把字符串形式的数字转成整型！
        Employee employee = employeeService.getEmployeeById(id);
        request.setAttribute("employee",employee);
        request.getRequestDispatcher("/toUpdateEmployee.jsp").forward(request,response);
    }
}
